home *** CD-ROM | disk | FTP | other *** search
/ World of Amiga / World of Amiga.iso / archive / music / oplay1231.lha / src / tmpnam.c < prev   
C/C++ Source or Header  |  1993-01-31  |  1KB  |  49 lines

  1. /*
  2.  * OmniPlay v1.23
  3.  * by David Champion
  4.  *
  5.  * temp-file name generator
  6.  * modified from my Amiga port of SOX, the Sound Exchange
  7.  * 17 Nov 92
  8.  */
  9. /*
  10.  * This is not needed under SAS/C version 6, but is left
  11.  * in case people want to use it in compiling with
  12.  * something else.
  13.  */
  14.  
  15. #include <exec/types.h>
  16. #include <string.h>
  17. #include <stdio.h>
  18.  
  19. #include "oplay.h"
  20.  
  21. #include <clib/exec_protos.h>
  22. #include <pragmas/exec_lib.h>
  23.  
  24. /*
  25.  * I used to use myname as the base for the temp file name,
  26.  * but then I realized that it doesn't work if, e.g., you
  27.  * call OmniPlay as "dh0:c/oplay chuckachucka.pp" --
  28.  * it tries to make a file called "t:dh0:c/o.XXXXXXXX" or
  29.  * something.  Obviously, this is unfair.
  30.  */
  31. //extern char *myname;    /* myname MUST exist! */
  32.  
  33.  
  34. char *tmpnam(char *s)
  35. {
  36. char tmp1[B_tmpnam+1], tmp2[64];
  37. //int i;
  38.  
  39. //old method; see above
  40. //strncpy(tmp1, myname, B_tmpnam);
  41. //sprintf(tmp2, "%s%s.%08x.%08x", P_tmpdir, tmp1, (ULONG)FindTask(NULL), (ULONG)time());
  42. strncpy(tmp1, PROGNAME, B_tmpnam);
  43. sprintf(tmp2, "%s%s.%08x", P_tmpdir, tmp1, (ULONG)FindTask(NULL));
  44.  
  45. strncpy(s, tmp2, L_tmpnam);
  46.  
  47. return(s);
  48. }
  49.